package org.robustcoupe.task;

import java.util.ArrayList;
import java.util.List;
import static org.robustcoupe.task.TaskResultType.*;

public class TaskChain extends AbstractFluentTask {
  private List<Task> tasks = new ArrayList<Task>();

  public TaskChain add(Task task) {
    tasks.add(task);
    return this;
  }

  public TaskResultType execute() {
    for (Task each : tasks) {
      //TODO I wonder whether this is a right design.
      validateTaskResult(each.execute());
    }
    return TaskResultType.SUCCESS;
  }
}
